﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using EntityFrameworks.Entity.Core.Specification;
 
namespace Common.Background.BLL
{
    public class DeptSpecification : Specification<WebDepartments>
    {
        #region Fields
        private string _deptName;
        #endregion

        #region Contructors
        public DeptSpecification(string deptName)
        {
            this._deptName = deptName;
        }
        #endregion

        #region Specification Overrides
        public override System.Linq.Expressions.Expression<Func<WebDepartments, bool>> SatisfiedBy()
        {
            Specification<WebDepartments> spec = new TrueSpecification<WebDepartments>();
            if (!string.IsNullOrWhiteSpace(_deptName))
                spec &= new DirectSpecification<WebDepartments>(o => o.DepartmentName.Contains(_deptName.Trim()));
            return spec.SatisfiedBy();
        }
        #endregion
    }
}